<script setup>
  import { useMouse } from "@vueuse/core";
  const { x, y } = useMouse();

  import * as echarts from "echarts";
  import { onMounted, ref } from "vue";

  const chartRef = ref(null);
  let echartClient = null;

  onMounted(()=> {
    initChart();
  });

  function initChart() {
    echartClient = echarts.init(chartRef.value);
    echartClient.setOption({
      tooltip: {},
      xAxis: {
        data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
      },
      yAxis: {},
      series: [
        {
          name: "销量",
          type: "bar",
          data: [5, 20, 36, 10, 10, 20]
        }
      ]
    });
  }
</script>

<template>
  <h1 class="success">This is a success style</h1>
  <h1 class="danger">This is a danger style</h1>
  <p>mouse current position: X:{{ x }}/Y:{{ y }}</p>
  <div class="chart-box" ref="chartRef"></div>
</template>

<style scoped lang="scss">
.success {
  color: $success;
}
.danger {
  color: $danger;
}
.chart-box {
  width: 600px;
  height: 400px;
}
</style>